package com.jsmtr.rms.controller.DoZZCJ;

import com.jsmtr.rms.entity.*;
import com.jsmtr.rms.service.*;
import com.jsmtr.rms.utils.EnumTools;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/Do/ZZCJExam")
public class DoZZCJExamController {

    @Resource
    private IUtilService utilService;
    @Resource
    private IDoSZService szService;
    @Resource
    private IDoBSService bsService;
    @Resource
    private IDoResumeService doResumeService;
    @Resource
    private IProjectService projectService;


    //[start] 笔试管理
    @RequestMapping("/")
    public String Index(HttpServletRequest request, HttpServletResponse response, Model model) {
        try {
            model.addAttribute("path", request.getContextPath());
            String pid = request.getParameter("pid").trim();
            String fid = request.getParameter("fid").trim();
            String deptcode = request.getParameter("deptcode").trim();

            model.addAttribute("pid", pid);
            model.addAttribute("fid", fid);
            model.addAttribute("deptcode", deptcode);

            //名族
            model.addAttribute("minzu", utilService.optionList("B", "0"));
            //婚否
            model.addAttribute("hunfou", utilService.optionList("D", "0"));
            //政治面貌
            model.addAttribute("zzmm", utilService.optionList("E", "0"));
            //最高学历
            model.addAttribute("education", utilService.optionList("F", "0"));
            //专业技术职务类型
            model.addAttribute("posttype", utilService.optionList("I", "0"));
            //职业资格证
            model.addAttribute("jndj", utilService.optionList("O", "0"));
            //招聘岗位
            List<ProjectInfoJobs> projectJobs=utilService.getProjectJobs(pid);
            model.addAttribute("jobs",projectJobs);

           /* //招聘岗位
            List<ProjectInfoJobs> jobs = projectService.getjobsbypid(pid);
            StringBuilder dstr = new StringBuilder();
            for (ProjectInfoJobs job : jobs) {
                dstr.append("<option value='" + job.getJobname() + "'>" + job.getJobname() + "</option>");
            }
            model.addAttribute("jobs", dstr);*/

            List<DoBSRoom> rooms = bsService.getRooms();
            StringBuilder roomsb = new StringBuilder();
            roomsb.append("<option value=''>请选择</option>");
            for (DoBSRoom room : rooms) {
                roomsb.append("<option value='" + room.getId() + "'>" + room.getName() +"["+room.getAllcount()+"人]"+ "</option>");
            }
            model.addAttribute("room", roomsb);

            List<BaseConfig> _configs = utilService.getConfigs("dxmb");
            StringBuilder str = new StringBuilder();
            for (BaseConfig _config : _configs) {
                str.append("<option value='" + _config.getCode() + "'>" + _config.getName() + "</option>");
            }
            model.addAttribute("dxmb", str);

            //面试注意事项
            String bszysx=utilService.getConfig("bszysx");
            model.addAttribute("bszysx",bszysx);

        } catch (Exception e) {
            e.printStackTrace();
        }
        return "Do/ZZCampusSpring/Exam/index";
    }

    //[end]
}
